<?php
$title = '职工';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title . '管理'); ?></h1>
<hr>
<div class="row">
    <?php
    $form = $this->form;
    $form->setAttribute('action', $this->url('staff/default', array('controller' => 'staff', 'action' => 'index')));
    $form->prepare();
    echo $this->form()->openTag($form);
    ?>
    <div class="col-md-2 col-xs-4" style="margin-bottom: 15px">
        <?php echo $this->formRow($form->get('id')); ?>
        <?php echo $this->formRow($form->get('column')); ?>
    </div>
    <div class="col-md-3 col-xs-5" style="margin-left: 2px;">
        <?php echo $this->formRow($form->get('parame')); ?>
    </div>
    <div class="col-md-1 col-xs-2" style="margin-left: 2px;">
        <?php echo $this->formSubmit($form->get('submit')); ?>
    </div>
    <?php echo $this->form()->closeTag(); ?>
    <a class="btn btn-primary"
       href="<?php echo $this->url('staff/default', array('controller' => 'staff', 'action' => 'add')); ?>">添加职工</a>
</div>
<table class="table table-hover table-striped">
    <tr>
        <th>身份证号</th>
        <th>姓名</th>
        <th>单位</th>
        <th>联系方式</th>
        <th>入职时间</th>
        <th>客户</th>
        <th>操作</th>
    </tr>
    <?php foreach ($this->staffs as $staff): ?>
        <tr>
            <td><?php echo $this->escapeHtml($staff->staff_id); ?></td>
            <td><?php echo $this->escapeHtml($staff->staff_name); ?></td>
            <td><?php echo $this->escapeHtml($staff->bank_name); ?></td>
            <td><?php echo $this->escapeHtml($staff->staff_tel); ?></td>
            <td><?php echo $this->escapeHtml($staff->start_time); ?></td>
            <td>
                <a href="<?php echo $this->url("staff/default", array("controller" => "client", "action" => "index", "id" => $staff->staff_id)); ?>">查看</a>
            </td>
            <td>
                <a class="btn btn-default"
                   href="<?php echo $this->url('staff/default', array('controller' => 'staff', 'action' => 'edit', 'id' => $staff->staff_id)); ?>">编辑</a>
                <a class="btn btn-danger"
                   href="<?php echo $this->url('staff/default', array('controller' => 'staff', 'action' => 'delete', 'id' => $staff->staff_id)); ?>">删除</a>
            </td>
        </tr>
    <?php endforeach; ?>
</table>
<script type="text/javascript">
    $("#column").val("<?php echo isset($_GET['column']) ? $_GET['column'] : null ?>");
    $("#parame").val("<?php echo isset($_GET['parame']) ? $_GET['parame'] : null ?>");
    $("#submit").click(function () {
        if ($("#column").val() == '') {
            alert('请选择查询项');
            $("#parame").val('');
        }
    });
</script>